module lsm(
        input   [15:0]  i_reglist,
        input   [ 4:0]  i_regcnt_dec,
        input   [ 3:0]  i_regcnt_inc,
        input           i_store,
        input   [ 3:0]  i_gpr_wa1,
        input           i_gpr_we0,

        output  [15:0]  o_reglist_fb,
        output  [ 4:0]  o_regcnt_dec_fb,
        output  [ 3:0]  o_regcnt_inc_fb,
        output  [ 3:0]  o_rd_sel_fb,
        output  [ 3:0]  o_gpr_wa1_fb,
        output          o_branch_wb_ldm,
        output          o_busy,
        output          o_gpr_we0
);

wire [3:0] ctz_out;

ctz16 u_ctz16_reglist(
        .in(i_reglist),
        .out(ctz_out)
);

assign o_reglist_fb = i_reglist & (i_reglist-16'b1);
assign o_regcnt_dec_fb = i_regcnt_dec-5'b1;
assign o_regcnt_inc_fb = i_regcnt_inc+4'b1;
assign o_rd_sel_fb = ctz_out;
assign o_gpr_wa1_fb = ctz_out;
assign o_branch_wb_ldm = ~i_store & &i_gpr_wa1;
assign o_busy = |i_regcnt_dec[4:1];
assign o_gpr_we0 = ~|i_regcnt_dec[4:1] & i_gpr_we0;

endmodule
